package com.lanou.dllo.soccernews.fragment.datasfragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import com.lanou.dllo.soccernews.R;

/**
 * Created by dllo on 15/11/4.
 */
public class EpLFragment extends Fragment {
private RadioGroup radioGroup;
    private RadioButton cent,shooter,attach,comeptition;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return  inflater.inflate(R.layout.fragment_datasview,null);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        radioGroup = (RadioGroup) view.findViewById(R.id.tab_menu);
        cent = (RadioButton) view.findViewById(R.id.da_cent);
        shooter = (RadioButton) view.findViewById(R.id.da_shooter);
        attach = (RadioButton) view.findViewById(R.id.da_attack);
        comeptition = (RadioButton) view.findViewById(R.id.da_competiton);

    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        getChildFragmentManager().beginTransaction().replace(
                R.id.da_replace,new CentFragment()).commit();
        radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                switch (checkedId){
                    case R.id.da_cent:
                        getChildFragmentManager().beginTransaction().replace(
                                R.id.da_replace,new CentFragment()).commit();
                        break;
                    case R.id.da_shooter:
                        getChildFragmentManager().beginTransaction().replace(
                                R.id.da_replace,new ShooterFragment()).commit();
                        break;
                    case R.id.da_attack:
                        getChildFragmentManager().beginTransaction().replace(
                                R.id.da_replace,new HelpAttackFragment()).commit();
                        break;
                    case R.id.da_competiton:
                        getChildFragmentManager().beginTransaction().replace(
                                R.id.da_replace,new CompetitonFragment()).commit();
                        break;
                    default:
                        break;
                }
            }
        });

    }
}
